package com.fau.wm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.time.DateFormatUtils;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 企业实体类
 * @author dangjh
 * @datetime 2014年10月14日,下午2:15:35
 */
@Entity
@Table(name = "medical_enterprise")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class MedicalEnterprise implements Serializable, JSONAware {

	private static final long serialVersionUID = 1038702809707818656L;

	private String id;
	
	@NotBlank(message = "企业名称不能为空！")
	@Length(max = 100, message = "企业名称长度需要在0和100之间")
	private String name;		// 企业名称
	private String provinceId;	// 省份id
	private String cityId;		// 城市id
	private String description;	// 企业描述
	
	private String needStatus;	// 是否需要对账、回款     1:对账      2:回款     3:对账、回款
	private String isLocked;
	private Date createTime = new Date();
	private Date updateTime = new Date();
	
	private String outSideNums;
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "name", length = 100)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "province_id", length = 10)
	public String getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(String provinceId) {
		this.provinceId = provinceId;
	}

	@Column(name = "city_id", length = 10)
	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

	@Column(name = "description", length = 500)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "need_status", length = 10)
	public String getNeedStatus() {
		return needStatus;
	}

	public void setNeedStatus(String needStatus) {
		this.needStatus = needStatus;
	}

	@Column(name = "is_locked", length = 2)
	public String getIsLocked() {
		return isLocked;
	}

	public void setIsLocked(String isLocked) {
		this.isLocked = isLocked;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Transient
	public String getOutSideNums() {
		return outSideNums;
	}

	public void setOutSideNums(String outSideNums) {
		this.outSideNums = outSideNums;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("name", name);
		obj.put("description", description);
		obj.put("needStatus", needStatus);
		obj.put("outSideNums", outSideNums);
		obj.put("provinceId", provinceId);
		obj.put("cityId", cityId);
		obj.put("isLocked", isLocked);
		obj.put("createTime", DateFormatUtils.format(createTime, "yyyy-MM-dd"));
		obj.put("updateTime", DateFormatUtils.format(updateTime, "yyyy-MM-dd"));
		return obj.toJSONString();
	}

}
